<template>
    <div class="list_page_div">
        <page-list :loading="loading" :table-config="tableConfig" :data-list="dataList" :height="height" show-index
                   show-page :total="total" :currentPage="param.pageNum" :pageSize="param.pageSize" @currentChange="handleCurrentChange"
        >
            <template #searchArea>
                <el-input v-model="param.messageTitle" clearable placeholder="消息标题" style="width: 200px;"></el-input>
                <el-input v-model="param.messageContent" clearable placeholder="消息内容" style="width: 200px;"></el-input>
                <el-button type="primary" @click="searchList">查询</el-button>
                <el-button type="primary" @click="resetData">重置</el-button>
            </template>

            <template #item_newsType="scope">
                {{ $common.getDicName('newsType', scope.row.newsType) }}
                <s @click="">{{ 审批详情 }}</s>
            </template>
            <template #item_approveId="scope">
                <s @click="detailData(scope.row.approveId)">{{ 审批详情 }}</s>
            </template>
        </page-list>
        <approve-detail :visible.sync="showDetail" :id="id" @refreshList="searchList"></approve-detail>
    </div>
</template>

<script>
import PageList from "@/components/grid/pageList.vue";
import ApproveDetail from "@/views/gateway/process/detail/approveDetail.vue";

export default {
    name: "messageList",
    components: {ApproveDetail, PageList},
    data() {
        return {
            height: 300,
            loading: false,
            showDetail: false,

            id: '',
            tableConfig: [
                {label: "消息类型", prop: "newsType", width: 300, slot: true},
                {label: "消息标题", prop: "messageTitle", width: 300},
                {label: "消息内容", prop: "messageContent", minWidth: 300},
                {label: "审批详情", prop: "approveId", width: 200, slot: true},
                {label: "创建时间", prop: "createTime", width: 200},
            ],
            dataList: [],
            total: 0,
            param: {
                messageTitle: '',
                messageContent: '',
                field: 'create_time',
                order: 'desc',
                pageSize: 20,
                pageNum: 1,
            }
        }
    },
    mounted() {
        this.$nextTick(() => {
            this.height = (document.body.offsetHeight - 185) + "px";
        })
        this.searchList();
    },
    methods: {
        handleCurrentChange(val) {
            this.param.pageNum = val;
            this.loading = true;
            this.searchList();
        },
        resetData() {
            this.param.messageTitle = '';
            this.param.messageContent = '';
            this.param.pageNum = 1;
            this.searchList();
        },
        searchList() {
            this.loading = true;
            this.$axios.post("/CHILD_SYSTEM/systemMessage/getPageList", this.param).then(res => {
                this.total = res.data.total;
                this.dataList = res.data.rows;
            }).finally(() => {
                this.loading = false;
            })
        },
        detailData(id) {
            this.id = id;
            this.showDetail = true;
        }
    }
}
</script>

<style scoped>

</style>